package com.springboot.dubbo.consumer.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.springboot.dubbo.consumer.service.UserConsumerService;
import com.springboot.dubbo.consumer.utils.SpringBeanFactoryUtil;
import com.springboot.dubbo.provider.api.bean.User;
import com.springboot.dubbo.provider.api.service.UserService;
import org.springframework.stereotype.Service;

/**
 * @Author: guodong
 * @Date: 2020/10/15 14:45
 * @Version: 1.0
 * @Description:
 */
@Service
public class UserServiceImpl implements UserConsumerService {

    @Reference(init = false, check = false, lazy = true)
    UserService userService;


    @Override
    public User getUserById(Long userId) {
        if (this.userService == null) {
            this.userService = SpringBeanFactoryUtil.getBean("userService",UserService.class);
        }
        return userService.getUserById(userId);
    }




}
